package com.tw.wechart2.util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.tw.wechart2.R;
/**
 * @Description: Glide工具类
 * @Author: lanteng 2020/9/16
 * @Version: 1.0
 */
public class GlideUtil {
    private static GlideUtil instance;

    public static GlideUtil instance() {
        if (instance == null) {
            synchronized (MyLogUtils.class) {
                if (instance == null) {
                    instance = new GlideUtil();
                }
            }
        }
        return instance;
    }

    /**
     * @Description: 加载网络图片展示
     * @Author: lanteng 2020/9/16
     * @return
     */
    public void displayImgage(Context context, String url, ImageView ivDisplay) {
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.placeholder(R.drawable.icon_seat);
        requestOptions.skipMemoryCache(false);
        requestOptions.timeout(150000);

        Glide.with(context)
                .load(url)
                .apply(requestOptions)
                .into(ivDisplay);
    }

    public void displayImgageNoPlace(Context context, String url, ImageView ivDisplay) {
        RequestOptions requestOptions = new RequestOptions();
//        requestOptions.placeholder(R.drawable.icon_seat);
        requestOptions.skipMemoryCache(true);

        Glide.with(context)
                .load(url)
                .apply(requestOptions)
                .into(ivDisplay);
    }

}
